package com.le.tester.javaThink.fifth.chapter12_Collections;

import com.le.tester.javaThink.fourth.typeinfo.pets.Pet;
import com.le.tester.javaThink.fourth.typeinfo.pets.Pets;

import java.util.*;


/**
 * createTime：2021/8/27 15:30
 * description：CrossCollectionIteration2
 */
public class CrossCollectionIteration2 {
    public static void display(Iterable<Pet> ip) {
        Iterator<Pet> it = ip.iterator();
        while (it.hasNext()) {
            Pet p = it.next();
            System.out.print(p.id() + ":" + p + " ");
        }
        System.out.println();
    }

    public static void main(String[] args) {
        List<Pet> pets = Pets.arrayList(8);
        LinkedList<Pet> petsLL = new LinkedList<>(pets);

        HashSet<Pet> petsHS = new HashSet<>(pets);
        TreeSet<Pet> petsTS = new TreeSet<>(pets);

        display(pets);
        display(petsLL);
        display(petsHS);
        display(petsTS);
    }
}
